import { requestClient } from '#/api/request';

export namespace LowcodeMagicApiApi {
  /** Magic API 配置信息 */
  export interface MagicApiConfig {
    baseUrl: string;
    webUrl: string;
    enabled: boolean;
    version?: string;
    status?: string;
  }

  /** Magic API 接口信息 */
  export interface ApiInfo {
    id: string;
    name: string;
    path: string;
    method: string;
    description?: string;
    createTime?: string;
    updateTime?: string;
  }
}

/** 获取Magic API配置信息 */
export function getMagicApiConfig() {
  return requestClient.get<LowcodeMagicApiApi.MagicApiConfig>('/lowcode/magic-api/config');
}

/** 获取Magic API状态 */
export function getMagicApiStatus() {
  return requestClient.get<any>('/lowcode/magic-api/status');
}

/** 获取Magic API接口列表 */
export function getMagicApiList() {
  return requestClient.get<LowcodeMagicApiApi.ApiInfo[]>('/lowcode/magic-api/api-list');
}

/** 重启Magic API服务 */
export function restartMagicApi() {
  return requestClient.post('/lowcode/magic-api/restart');
}

/** 清除Magic API缓存 */
export function clearMagicApiCache() {
  return requestClient.post('/lowcode/magic-api/clear-cache');
}

/** 同步Magic API数据库表结构 */
export function syncMagicApiDatabase() {
  return requestClient.post('/lowcode/magic-api/sync-database');
}